package com.zues.thread.method.park;

import com.zues.thread.util.ThreadUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

/**
 * 测试park和unpark
 */
@Slf4j(topic = "c.TestParkUnpark")
public class TestParkUnpark {


    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            log.debug("start...");
            ThreadUtil.sleep(1);
            log.debug("park...");
            LockSupport.park();
            log.debug("resume...");
        }, "t1");

        t1.start();
        ThreadUtil.sleep(4);
        log.debug("unPark...");
        LockSupport.unpark(t1);
        log.debug("main finish...");
    }


}
